/*
 * watch_plot.h
 *
 *  Created on: 13.06.2013
 *      Author: SpirTanol
 */

#ifndef WATCH_PLOT_H_
#define WATCH_PLOT_H_

// QT
#include <QObject>

// Qwt
#include <qwt_plot.h>

class QwtPlotCurve;

class WatchPlot : public QwtPlot
{
	Q_OBJECT

	QVector<double> oTimes;
	struct CurveData
	{
		QwtPlotCurve *oCurve;
		QVector<double> oData;
	};
	CurveData oCurves[6];

	double oLeftMax;
	double oRightMax;
	uint oDuration;
	bool oF; /**< Если true значит ток делится на 10 */

private slots:
	void showCurve(QwtPlotItem *, bool on);

public:
	enum Curve
	{
		C_CURRENT_A,
		C_CURRENT_B,
		C_CURRENT_C,

		C_VOLTAGE_A,
		C_VOLTAGE_B,
		C_VOLTAGE_C,
	};

	WatchPlot();
	WatchPlot(const WatchPlot *watchPlot);
	~WatchPlot();

	void restart();

	void updateData(double current[3], double voltage[3]);

	inline void setDuration(uint duration) { oDuration = duration; }
	inline uint duration() const { return oDuration; }

	inline void setFract(bool f) { oF = f; }
	inline bool isFract() const { return oF; }

private:
	void init();

};

#endif /* WATCH_PLOT_H_ */
